package com.gitee.hermer.engine.jars.dependent.dubbo.configuration;

import java.util.Map;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.Ordered;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.gitee.hermer.boot.jee.commons.log.UtilsContext;
import com.gitee.hermer.boot.jee.commons.utils.StringUtils;
import com.gitee.hermer.boot.jee.commons.verify.Assert;
import com.gitee.hermer.engine.jars.dependent.dsm.IEnginePropertiesAware;
import com.gitee.hermer.engine.jars.dependent.dubbo.config.DubboProperties;
import com.gitee.hermer.engine.jars.dependent.zkclient.config.ZkClientProperties;
import com.gitee.hermer.engine.jars.dependent.zkclient.configuration.ZkClientAutoConfiguration;

@Configuration
@Import(ZkClientAutoConfiguration.class)
public class DubboRegistryAutoConfiguration extends UtilsContext  implements Ordered{
	
	
	@Bean
	@Autowired
	public RegistryConfig registry(DubboProperties dubboProperties,ZkClientProperties zkProperties) {
		Assert.hasText(zkProperties.getResAddress());
		Assert.hasText(dubboProperties.getProtocol());
		RegistryConfig registryConfig = new RegistryConfig(zkProperties.getResAddress());
		registryConfig.setUsername(zkProperties.getResUsername());
		registryConfig.setPassword(zkProperties.getResPassowrd());
		registryConfig.setProtocol(dubboProperties.getProtocol());
		return registryConfig;
	}
	
	


	@Override
	public int getOrder() {
		return HIGHEST_PRECEDENCE+1000;
	}
	
	
	
	
}
